package com.scau.XFourPOS.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 类名称：Product
 * 类描述：产品的model
 * 创建人：庄祥鹏
 * */
@Entity
@Table(name = "product")
public class Product {
	/**
	 * 产品id
	 */
	@Id
	@Column(name = "product_id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int productId;

	/**
	 * 产品条形码
	 */
	@Column(name = "code", length = 50)
	private String code;

	/**
	 * 产品名
	 */
	@Column(name = "name", length = 50)
	private String name;

	/**
	 * 产品描述
	 */
	@Column(name = "description")
	private String description;

	/**
	 * 图片链接地址
	 */
	@Column(name = "photo_url", length = 50)
	private String photoUrl;

	/**
	 * 产品类别， 多对一对应ProductCategory表，属于夹克、裤子或什么什么的
	 */
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = ProductCategory.class)
	private ProductCategory productCategory;

	/**
	 * 产品颜色 多对一对于ProductColor表
	 */
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = ProductColor.class)
	private ProductColor productColor;

	/**
	 * 产品存货，一对多对应ProductStock表
	 */
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,targetEntity=ProductStock.class,mappedBy="productStockPK.product")
	private Set<ProductStock> productStock;

	/**
	 * getter and setter
	 */
	public String getCode() {
		return code;
	}

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getPhotoUrl() {
		return photoUrl;
	}

	public void setPhotoUrl(String photoUrl) {
		this.photoUrl = photoUrl;
	}

	public ProductCategory getProductCategory() {
		return productCategory;
	}

	public void setProductCategory(ProductCategory productCategory) {
		this.productCategory = productCategory;
	}

	public ProductColor getProductColor() {
		return productColor;
	}

	public void setProductColor(ProductColor productColor) {
		this.productColor = productColor;
	}

	public Set<ProductStock> getProductStock() {
		return productStock;
	}

	public void setProductStock(Set<ProductStock> productStock) {
		this.productStock = productStock;
	}

	/**
	 * 构造方法
	 */
	/*
	 * public Product(){
	 * 
	 * }
	 */

}
